package com.zhucan.tenant.datasource.mybatis;

import com.baomidou.mybatisplus.extension.plugins.inner.DynamicTableNameInnerInterceptor;
import com.zhucan.tenant.datasource.DatasourceContextHolder;

/**
 * @author zhuCan
 * @description
 * @since 2023/3/17 17:02
 */
public class DatasourceDynamicTableNameInnerInterceptor extends DynamicTableNameInnerInterceptor {

  public DatasourceDynamicTableNameInnerInterceptor(DatasourceContextHolder contextHolder){

    setTableNameHandler((sql, tableName) -> contextHolder.tenantDatabaseName()+"."+tableName);
  }
}